<input id="input" type="text" /><br>
<span id="span"></span><br>
<button id="btn1">一般修改</button>
<button id="btn2">触发input修改</button>

<script>
	class c_data{
		constructor(){
			this.valueSave="默认文本";
			this.input=document.querySelector("#input");
			this.span=document.querySelector("#span");
			this.input.value=this.valueSave;
			this.span.innerHTML=this.valueSave;
			this.input.addEventListener("input",(e) => {
				this.value=this.input.value;
			});
		}
		get value(){
			return this.valueSave;
		}
		set value(val){
			this.input.value=val;
			this.valueSave=val;
			this.span.innerHTML=val;
		}
	}

	const data=new c_data();

	document.querySelector("#btn1").addEventListener("click",(e) => {
		const el=document.querySelector("#input");
		el.value="修改内容1";
	});

	document.querySelector("#btn2").addEventListener("click",(e) => {
		const el=document.querySelector("#input");
		el.value="修改内容2";
    el.dispatchEvent(new Event('input'));
	});
</script>